/*******************************************************************************
 * Copyright (c) 2010, 2015 git@git.oschina.net:kaiwill/springstage.git
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.qinyeit.serviceapp.service.system;

import com.alibaba.fastjson.JSONObject;
import com.qinyeit.serviceapp.entity.enums.Scope;
import com.qinyeit.serviceapp.entity.system.ManagementPermission;
import com.qinyeit.serviceapp.entity.system.ManagementRole;
import com.qinyeit.serviceapp.exception.CanNotDeleteException;
import com.qinyetech.springstage.core.service.IBaseService;
import org.springframework.validation.BindingResult;

import java.util.List;
import java.util.Map;

/** 
 * ClassName: ManagementRoleService <br/>
 * Function: 角色服务 <br/> 
 * date: 2015年10月6日 上午11:52:11 <br/> 
 * 
 * @author wuqing 
 * @version  
 * @since JDK 1.7 
 */
public interface ManagementRoleService extends IBaseService<ManagementRole, Long> {

	/**
	 * 验证是否有重复值
	 * @param id 记录ID
	 * @param name 名称
	 * @param code 编码
     * @return
     */
	public boolean existsRepeat(BindingResult result, Long id, String name, String code);

	public ManagementRole findByCode(String code);

	/**
	 * authorization:为角色授权 <br/>
	 * @author wuqing
	 * @since JDK 1.7
	 */
	public ManagementRole authorization(long systemRoleId, List<Long> permissionIds);

	public void updateChildRole(ManagementRole role, List<ManagementRole> childs);

	public ManagementRole authorization(ManagementRole role, List<ManagementPermission> permissionList);
	public void destroy(Long id) throws CanNotDeleteException;

	/**
	 *
	 * 保存数据
	 * @param data
	 * @param merchantGroupId
	 */
	void saveData(JSONObject data,Long merchantGroupId,String operator);

	/**
	 * 获取岗位权限
	 * @param roleId
	 * @return
	 */
	List<Object> getPermission(Long roleId);

	/**
	 * 获取门店权限
	 * @param scope
	 * @return
	 */
	List<Long> getBranchPermissions(Long roleId,Scope scope);

	/**
	 * 获取角色
	 * @param merchantGroupId
	 * @return
	 */
	List<ManagementRole> getPositions(Long merchantGroupId);

}
